<template>
  <div class="form">
    <el-form :label-position="labelPosition" label-width="80px" :model="formInfo">
      <el-form-item label="登录名">
        <el-input v-model="formInfo.name" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="原密码">
        <el-input v-model="formInfo.region" type="password"></el-input>
      </el-form-item>
      <el-form-item label="新密码">
        <el-input v-model="formInfo.type" type="password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('formInfo')">确定</el-button>
        <el-button @click="resetForm('formInfo')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      labelPosition: "right",
      formInfo: {
        name: window.localStorage.getItem("username"),
        region: "",
        type: ""
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>
<style lang="scss" scoped>
.form{
  width: 350px;
  height: 300px;
  position: relative;
  margin-left:30%;
}
</style>
